﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SmartProject.BusinessRules
{
    /// <summary>
    /// Password is a required field in some instances. This business rule
    /// validates which when password is required and fires the appropriate
    /// message.
    /// </summary>
    public class PasswordCheck : BusinessRule
    {
        public override string Name
        {
            get { return String.Empty; }
        }

        public override string Description
        {
            get { return String.Empty; }
        }

        public override void Implement(Entity data)
        {
            if (data.StoredProc == "smartProject_AddUser")
            {
                string password = (string)data.GetBusinessRuleParameterValue("Password");
                if (String.IsNullOrEmpty(password))
                {
                    throw new Exceptions.BusinessRuleViolation("Password is a required field.");
                }
            }
        }

        public override bool QueryBooleanProperty(string propertyName)
        {
            return NotQueryable;
        }
    }
}
